package gitee.derumin.lib_for_derumin.helpers.config.configserializers;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.util.JsonHelper;

public class ItemSerializer implements ConfigFieldSerializer<Item> {
    @Override
    public Item jsonToObject(JsonElement element, String name) {
        return JsonHelper.asItem(element, name);
    }

    @Override
    public JsonElement objectToJson(Object contains) {
        return new JsonPrimitive(Registries.ITEM.getId((Item) contains).toString());
    }
}
